package cn.kgc.springcloud.controller;

import cn.kgc.springcloud.entity.Group;
import cn.kgc.springcloud.service.GroupService;
import cn.kgc.springcloud.vo.GroupVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * @author 课工场
 * @date 2023/10/19
 * @description
 */
@RestController
@RequestMapping("group")
public class GroupController {

    @Resource
    private GroupService groupService;

    @GetMapping
    public List<GroupVO> getList() {

        return groupService.getList();
    }

    @PostMapping
    public Group addGroup(@RequestBody Group group) {

        group.setCreatedate(new Date());

        groupService.save(group);

        return group;

    }


    @GetMapping("{id}")
    public Group  getById(@PathVariable Integer id){

        return groupService.getById(id);
    }

}
